package com.ztc.ZtcClassesSite.web;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ztc.ZtcClassesSite.bean.ZtcClassesSite;
import com.ztc.ZtcClassesSite.service.ZtcClassesSiteManager;

import java.util.HashMap;
import java.util.List;
@Controller
@RequestMapping("ztc_classes_site_action")
public class ZtcClassesSiteAction{
    @Autowired
    private ZtcClassesSiteManager  ztcClassesSiteManager;
    private static final Logger log = LogManager.getLogger(ZtcClassesSite.class);

    @RequestMapping("init")
    @ResponseBody
    public HashMap<String, Object> getAll() {
        List<ZtcClassesSite> list = ztcClassesSiteManager.getAll();
        HashMap<String, Object> wapper = new HashMap<>();
        wapper.put("success", Boolean.valueOf(true));
        wapper.put("data", list);
        log.debug("lists",list);
        return wapper;
    }

    /**
     * 根据名称，城市，负责人电话查询站点信息
     * @param name 名称
     * @param areaCity 城市
     * @param managerPhone 负责人电话
     * @return 站点集合
     */
    @RequestMapping("searchInfoLikes")
    @ResponseBody
    public HashMap<String, Object> searchInfoLikes(String name,String areaCity,String managerPhone) {
        List<ZtcClassesSite> list = ztcClassesSiteManager.searchInfoLikes(name,areaCity,managerPhone);
        HashMap<String, Object> wapper = new HashMap<>();
        wapper.put("success", Boolean.valueOf(true));
        wapper.put("data", list);
        log.debug("lists",list);
        return wapper;
    }
}